package databaseVersionControl.domain.factory.composite;

import databaseVersionControl.domain.db.DBComponent;
import databaseVersionControl.domain.dialect.Dialect;
import databaseVersionControl.domain.script.ExecutableScript;
import databaseVersionControl.infra.script.validation.PreInstallCondition;

public class DropComposite<T extends DBComponent> implements ExecutableScript {

	private T component;
	private final String statement = "DROP ";
	private PreInstallCondition<?> preInstallCondition;

	public DropComposite(T component) {
		this.component = component;
	}

	@Override
	public String sqlInDialect(Dialect dialect) {
		return sqlIdentifier();
	}

	@Override
	public String sqlIdentifier() {
		return statement + component.sqlIdentifier();
	}

	@Override
	public String getName() {
		return component.getName();
	}

	@Override
	public PreInstallCondition<?> getPreInstallCondition() {
		return preInstallCondition;
	}

	@Override
	public boolean hasPreInstallCondition() {
		return getPreInstallCondition() != null;
	}

}
